﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameEndItemPage : EventManager
{
    public RawImage headImg;
    public Text name;
    public Text id;
    public Text winCounts;
    public Text defeatCounts;
    public Text totalScoreTex;

    public override void InformationSetting()
    {

    }

    public void InitGameEndItem(Player player) 
    {
        headImg.texture = player.headTexture;
        SetText(name, player.userName);
        SetText(id, "ID：" + player.userId);
        SetText(winCounts, string.Format("获胜{0}局", player.winCounts));
        SetText(defeatCounts, string.Format("失败{0}局", player.defeatCounts));
        SetTotalScore(player.UserTotalScore.ToString());
    }

    public void SetTotalScore(string totalScore)
    {
        if (totalScore.Substring(0, 1) == "-")
        {
            SetText(totalScoreTex, string.Format("<color=red>{0}</color>", totalScore));
        }
        else
        {
            SetText(totalScoreTex, string.Format("<color=green>+{0}</color>", totalScore));
        }
    }
}
